package fiarproject;

import java.util.Stack;

/**
 * Created by IntelliJ IDEA.
 * User: Luke
 * Date: 14/08/11
 * Time: 15:34
 * To change this template use File | Settings | File Templates.
 */
// TODO: Ensure all exceptions are being caught in the right place
 //TODO: Tidy up class, make sure that class conforms well to the way Java normally deals with exceptions
public class FiarException extends Exception {
   public FiarException() {
        super();
    }

    public FiarException(String s) {
        super(s);
        System.err.println(s);
    }

    /***
     *
     * @param errors Stack containing erroneous lines inpuut
     */
    public FiarException(Stack errors) {
        displayErrors(errors);
    }

    private void displayErrors(Stack errors) {
        System.err.println("Syntax error at: ");
        System.err.print("Line " + errors.pop());
        while (!errors.empty()) {
            System.err.print(", line " + errors.pop());
        }
        System.err.print(".");
    }
}
